import 'package:flutter/material.dart';

void main() {
  // 1. 运行应用程序。
  runApp(const MaterialApp(
    home: Main(),
  ));
}

class Main extends StatelessWidget {
  const Main({super.key});
//  {
//     "createTime": "2024-08-15 21:49:48",
//     "orderState": 2,
//     "image": "https://yanxuan-item.nosdn.127.net/a09de222ed32efa8ffe359b1d5780574.jpg",
//     "name": "茶水分离杯耐热隔热玻璃杯",
//     "totalNum": 2,
//     "curPrice": 119.5,
//     "totalMoney": 119.5,
//     "attrsText": "规格:白色240ml"
// }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text(
          '案例 - 订单商品信息',
          style: TextStyle(color: Colors.white),
        ),
        backgroundColor: Colors.purple,
      ),
      body: Container(
        padding: const EdgeInsets.all(10),
        color: Colors.black12,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.end,
          children: [
            const Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text('2024-08-15 21:49:48'),
                Text(
                  '待发货',
                  style: TextStyle(color: Colors.amber),
                ),
              ],
            ),
            const SizedBox(height: 10), // 充当 margin 角色
            Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Image.network(
                  'https://yanxuan-item.nosdn.127.net/a09de222ed32efa8ffe359b1d5780574.jpg',
                  height: 100,
                  width: 100,
                ),
                const SizedBox(
                  width: 10,
                ),
                Expanded(
                  child: SizedBox(
                    height: 100,
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        const Text(
                          '茶水分离杯 耐热隔热玻璃杯  茶水分离杯 耐热隔热玻璃杯 茶水分离杯 耐热隔热玻璃杯 茶水分离杯 耐热隔热玻璃杯茶水分离杯耐热隔热玻璃杯茶水分离杯耐热隔热玻璃杯',
                          maxLines: 2,
                          overflow: TextOverflow.ellipsis,
                        ),
                        Container(
                          padding: const EdgeInsets.symmetric(
                              vertical: 2, horizontal: 5),
                          decoration: BoxDecoration(
                              color: Colors.white54,
                              borderRadius: BorderRadius.circular(5)),
                          child: const Text(
                            '规格:白色240ml',
                            style: TextStyle(
                              color: Colors.grey,
                            ),
                          ),
                        ),
                        const Text('¥119.5'),
                      ],
                    ),
                  ),
                ),
                const Text(
                  'x 2',
                  style: TextStyle(height: 3),
                )
              ],
            ),
            // 底部合计 + 按钮
            const Text('合计：¥239.00'),
            const SizedBox(height: 10), // 间隔
            Row(
              mainAxisSize: MainAxisSize.min, // 根据内容调整宽度
              children: [
                ElevatedButton(
                  onPressed: () {},
                  child: const Text('查看详情'),
                ),
                const SizedBox(width: 10),
                FilledButton(
                  onPressed: () {},
                  child: const Text('再次购买'),
                )
              ],
            )
          ],
        ),
      ),
    );
  }
}
